from lxml import etree
from lxml.builder import E
import logging
_logging = logging.getLogger(__name__)
xml = etree.parse('./ir_actions_act_window.xml')
root = xml.getroot()


def generate_actions_py(root):
    # for record in root:
    res_model = root.xpath("//field[@name='res_model']")
    for model_name in res_model:
        model = model_name.text
        # print(model)
        if 'x_' in model:
            model_tem = model.replace("x_", "einfo_")
            tem = model_tem.replace("_", ".")
            model_name.text = tem

    xml = etree.tostring(root, pretty_print=True,
                         encoding='UTF-8', xml_declaration=True)
    # print(xml)
    return root


generate_actions_py(root)
